#include "LaserReceiver.h"
#include "Events\CSGD_EventSystem.h"

#include "../SGD Wrappers/CSGD_Direct3D.h"
#include "Camera.h"

LaserReceiver::LaserReceiver(void)
{
	objectID = "Laser Receiver";
	isPowered = false;
}


LaserReceiver::~LaserReceiver(void)
{
}


void LaserReceiver::Update(float deltaTime)
{
	//isPowered is set in LaserEmitter by linecast
	if(isPowered)
	{
		CSGD_EventSystem::GetInstance()->SendEvent("Receiver Activate", (void*)0, (void*)0, (void*)this);
	}
	else
	{
		CSGD_EventSystem::GetInstance()->SendEvent("Receiver Deactivate", (void*)0, (void*)0, (void*)this);
	}

	isPowered = false;
}
void LaserReceiver::Render(void) const
{
	{
		RECT box = hitBox;
		box.left = (int)(box.left - Camera::GetInstance()->OffsetX());
		box.right = (int)(box.right - Camera::GetInstance()->OffsetX());
		box.bottom = (int)(box.bottom - Camera::GetInstance()->OffsetY());
		box.top = (int)(box.top - Camera::GetInstance()->OffsetY());

		CSGD_Direct3D::GetInstance()->DrawHollowRect(box,D3DCOLOR_ARGB(255,255,0,0));
	}
	if(imageID != -1)
	{
		CSGD_TextureManager::GetInstance()->Draw(imageID,(int)(positionX - Camera::GetInstance()->OffsetX()),(int)(positionY - Camera::GetInstance()->OffsetY()));
	}
	//TODO: Display differently if powered?
}

//void LaserReceiver::HandleCollision(GameObject& other, CollisionInfo& info)
//{
//
//}